<div class="add-host-question MgT20">

</div>


<script>
    $(document).ready(function () {
        getHotQuestion('default', 0);
        $(document).on('click', '.pre-view-click', function (e) {

            var page = $(this).attr('href').split('click_next_preview_question=')[1];
            var category_id = $('#hot_category').val();
            getHotQuestion(page, category_id);
            e.preventDefault();
        });
        $(document).on('click', '.next-view-click', function (e) {
            var page = $(this).attr('href').split('click_next_preview_question=')[1];
            var category_id = $('#hot_category').val();
            getHotQuestion(page, category_id);
            e.preventDefault();
        });

        $(document).on('change', '#hot_category', function (e) {
            var page = 0;
            var category_id = $('#hot_category').val();
            getHotQuestion(page, category_id);
            e.preventDefault();
        });
    });

    function  getHotQuestion(page, category_id) {
        $.ajax({
            type: 'POST',
            url: '<?= route('hoi-dap') ?>/hotquestion?click_next_preview_question=' + page + '&category_id=' + category_id,
            dataType: 'json',
        }).done(function (data) {
            $('.add-host-question').html(data);
            // location.hash = '?page_answer='
        }).fail(function () {
            alert('Posts could not be loaded.');
        });
    }

</script>
